import { _decorator, Label, math, Sprite } from "cc";
import { ScrollListCell } from "../../comp/ScrollListCell";
const { ccclass } = _decorator;

/**
 * 登陆界面服务器列表单元格
 */
@ccclass("LoginSvrCell")
export class LoginSvrCell extends ScrollListCell {

    onRender() {
        let bg = this.getChildComp("Bg", Sprite);
        let labName = this.getChildComp("LabName", Label);
        let labState = this.getChildComp("LabState", Label);
        bg.color = this.selected ? math.color(255, 233, 133, 233) : math.color(255, 233, 188, 233);
        labName.string = this.data.name;
        if (this.data.state) {
            labState.color =
                this.data.load == 0 ? math.color(0, 255, 0)
                    : this.data.load == 1 ? math.color(255, 133, 0)
                        : this.data.load == 2 ? math.color(255, 0xCC, 0x00) :
                            math.color(255, 0, 0);
        } else {
            labState.color = math.color(123, 123, 123);
        }
    }

}